USE [Snap]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CompanyNewsToCompany]') AND parent_object_id = OBJECT_ID(N'[dbo].[NewsToCompanies]'))
ALTER TABLE [dbo].[NewsToCompanies] DROP CONSTRAINT [FK_CompanyNewsToCompany]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_NewsItemNewsToCompany]') AND parent_object_id = OBJECT_ID(N'[dbo].[NewsToCompanies]'))
ALTER TABLE [dbo].[NewsToCompanies] DROP CONSTRAINT [FK_NewsItemNewsToCompany]
GO

USE [Snap]
GO

/****** Object:  Table [dbo].[NewsToCompanies]    Script Date: 07/01/2010 13:10:59 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[NewsToCompanies]') AND type in (N'U'))
DROP TABLE [dbo].[NewsToCompanies]
GO

USE [Snap]
GO

/****** Object:  Table [dbo].[NewsToCompanies]    Script Date: 07/01/2010 13:10:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[NewsToCompanies](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[NewsItemId] [int] NOT NULL,
	[CompanySymbol] [nvarchar](10) NOT NULL,
 CONSTRAINT [PK_NewsToCompanies] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[NewsToCompanies]  WITH CHECK ADD  CONSTRAINT [FK_CompanyNewsToCompany] FOREIGN KEY([CompanySymbol])
REFERENCES [dbo].[Companies] ([Symbol])
GO

ALTER TABLE [dbo].[NewsToCompanies] CHECK CONSTRAINT [FK_CompanyNewsToCompany]
GO

ALTER TABLE [dbo].[NewsToCompanies]  WITH CHECK ADD  CONSTRAINT [FK_NewsItemNewsToCompany] FOREIGN KEY([NewsItemId])
REFERENCES [dbo].[NewsItems] ([Id])
GO

ALTER TABLE [dbo].[NewsToCompanies] CHECK CONSTRAINT [FK_NewsItemNewsToCompany]
GO

